package cn.cs.controller;

import cn.cs.common.Dto;
import cn.cs.common.DtoUtil;
import cn.cs.service.AgentSettlementService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/agentSettlement")
public class AgentSettlementController {
    @Resource
    private AgentSettlementService service;
    /****
     * 经销商我的账户
     * @param
     * @param
     * @return
     */
    @RequestMapping("/agentBalance")
    @ResponseBody
    public Dto agentBalance(HttpServletRequest request, HttpServletResponse response){
        Dto dto=null;
        try {
            response.setHeader("Access-Control-Allow-Origin", "*");
            dto=service.agentBalance(request);
        }catch (Exception e){
            e.printStackTrace();
            return DtoUtil.returnFail("查询失败","002");
        }
        return dto;
    }
    /****
     * 经销商结算历史列表
     * @param
     * @param
     * @return
     */
    @RequestMapping("/agentSeetHisList")
    @ResponseBody
    public Dto agentSeetHisList(HttpServletRequest request, HttpServletResponse response){
        Dto dto=null;
        try {
            response.setHeader("Access-Control-Allow-Origin", "*");
            dto=service.agentSeetHisList(request);
        }catch (Exception e){
            e.printStackTrace();
            return DtoUtil.returnFail("查询失败","002");
        }
        return dto;
    }

    /****
     * 经销商结算详情
     * @param
     * @param
     * @return
     */
    @RequestMapping("/agentSeetInfo")
    @ResponseBody
    public Dto agentSeetInfo(HttpServletRequest request, HttpServletResponse response){
        Dto dto=null;
        try {
            response.setHeader("Access-Control-Allow-Origin", "*");
            dto=service.agentSeetInfo(request);
        }catch (Exception e){
            e.printStackTrace();
            return DtoUtil.returnFail("查询失败","002");
        }
        return dto;
    }
    /****
     * 资金池动态列表接口
     * @param
     * @param
     * @return
     */
    @RequestMapping("/capitalInfoList")
    @ResponseBody
    public Dto capitalInfoList(HttpServletRequest request, HttpServletResponse response){
        Dto dto=null;
        try {
            response.setHeader("Access-Control-Allow-Origin", "*");
            dto=service.capitalInfoList(request);
        }catch (Exception e){
            e.printStackTrace();
            return DtoUtil.returnFail("查询失败","002");
        }
        return dto;
    }

}
